<!--
 * @Description: 我的
 * @Author: lipenghui
 * @Date: 2023-07-14 16:46:15
 * @LastEditors: 1960116313@qq.com 1960116313@qq.com
 * @LastEditTime: 2023-10-24 17:18:17
-->
<template>
  <view class="user">
    <view class="loginout" @click="handleLoginOut">退出登录</view>

    <view class="loginout" @click="copy('1234')">复制1234</view>

    <view class="throttle" @tap="$u.throttle(btnAClick, 500)">
      节流
    </view>

    <view class="debounce" @tap="$u.debounce(btnBClick, 2500)">
      防抖
    </view>

    <view class="debounce">
      时间格式化
      <view>
        时间为：{{ $u.timeFormat(timestamp, 'yyyy/mm/dd') }}
      </view>

    </view>
    <u-modal v-model="loginOutshow" show-cancel-button :content="content" @confirm="LoginOut"></u-modal>
    <tabbar />
  </view>
</template>
<script setup>
import { onReady, onShow, onLoad } from "@dcloudio/uni-app";
import { ref, reactive, computed } from "vue";
import { statistics } from "@/api/user";
import { userStore } from "@/store/user/user";
import { useCopy } from "@/hooks/useCopy";
const { copy } = useCopy();
const userStores = userStore();
import { getToken } from "@/utils/auth";

const timestamp = '1581170184'

const loginOutshow = ref(false);
const content = "确认要退出吗？";

//退出弹框
const handleLoginOut = () => {
  loginOutshow.value = true;
};
//确认退出
const LoginOut = () => {
  userStores.logout();
  if (!getToken()) {
    uni.reLaunch({
      url: "/pages/login/index",
    });
  }
};

//节流
const btnAClick = () => {
  console.log(11111111111, "节流");
}
//防抖
const btnBClick = () => {
  console.log(11111111111, "防抖");
}
</script>
<style lang="scss" scoped>
.user {
  width: 100%;

  .loginout {
    width: 95%;
    margin: 20rpx auto 0;
    height: 90rpx;
    background: #ffffff;
    border-radius: 20rpx;
    font-size: 31rpx;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #606266;
    line-height: 90rpx;
    text-align: center;
  }

  .throttle {
    margin-top: 50rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100rpx;
    border: 1px solid $u-type-primary;
  }

  .debounce {
    margin-top: 50rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100rpx;
    border: 1px solid $u-type-primary;
  }
}
</style>
